//
//  TeacherVipCollectionViewCell.m
//  Civacrm
//
//  Created by mubei on 17/2/23.
//  Copyright © 2017年 王桂敏. All rights reserved.
//

#import "TeacherVipCollectionViewCell.h"
#import "SchoolPageInfoModel.h"

@implementation TeacherVipCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)createView{
    
    
    
    self.lowMiddelStudentLable = [[UILabel alloc] init];
    self.studentLable = [[UILabel alloc]init];
    self.studentLable.font = font(24);
    [self addSubview:self.studentLable];
    
    self.studentButton = [[UILabel alloc]init];
//    [self.studentButton setTitle:@"详情" forState:UIControlStateNormal];
//    [self.studentButton setTitleColor:ColorWithHexString(@"6dbfee") forState:UIControlStateNormal];
    self.studentButton.text = @"详情";
    self.studentButton.textAlignment =  NSTextAlignmentCenter;
    self.studentButton.textColor = ColorWithHexString(@"6dbfee");

    self.studentButton.font = font(24);
    [self.studentButton.layer setMasksToBounds:YES];
    [self.studentButton.layer setCornerRadius:5.0]; //设置矩形四个圆角半径
    [self.studentButton.layer setBorderWidth:1.0]; //边框宽度
    //    [self.studentButton addTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];
    [self.studentButton.layer setBorderColor:ColorWithHexString(@"6dbfee").CGColor];//边框颜色
    [self addSubview:self.studentButton];
}
- (void)layoutSublayersOfLayer:(CALayer *)layer{
    [super layoutSublayersOfLayer:layer];
    self.PieCharLogViewStudent.frame = CGRectMake(w(70),h(50), w(180), h(180));
    self.bigCircleLable.frame = CGRectMake(w(70)+ w(32),h(32) + h(50), (w(90)-w(32))*2, (w(90)-w(32))*2);
    self.lowMiddelStudentLable.frame = CGRectMake(0, 0, 0, 0);
    [self.lowMiddelStudentLable sizeToFit];
    self.lowMiddelStudentLable.center = self.bigCircleLable.center;
    self.studentLable.frame = CGRectMake(getMinX(self.PieCharLogViewStudent), getMaxY(self.PieCharLogViewStudent) + h(21), 0, 0);
    [self.studentLable sizeToFit];
    self.studentLable.centerX = self.PieCharLogViewStudent.centerX;
    self.studentButton.frame = CGRectMake(0, getMaxY(self.studentLable)+h(23), w(100), h(38));
    self.studentButton.centerX = self.PieCharLogViewStudent.centerX;


    
    
    
}
- (void)setSchoolPageInfoModel:(SchoolPageInfoModel *)schoolPageInfoModel{
    if (self.schoolPageInfoModel != schoolPageInfoModel) {
        _schoolPageInfoModel = schoolPageInfoModel;
    }
    //    self.stringStudent = [NSString stringWithFormat: @"%ld/%ld", self.schoolPageInfoModel.studentLoginCounts,self.schoolPageInfoModel.teacherCounts];
    
}
- (void)setPieArray:(NSMutableArray *)pieArray{
    if (self.pieArray != pieArray) {
        _pieArray = pieArray;
    }
    self.PieCharLogViewStudent =[[LXMPieView alloc] initWithFrame:CGRectMake(w(70), 0, w(180), h(180)) values:pieArray];
    [self addSubview:self.PieCharLogViewStudent];
    
    self.bigCircleLable = [[UILabel alloc] init];
    self.bigCircleLable.backgroundColor = WhiteColor;
    self.bigCircleLable.layer.masksToBounds = YES;
    self.bigCircleLable.layer.cornerRadius = h(90)-h(32);
    [self addSubview:self.bigCircleLable];
    self.bigCircleLable.center = self.PieCharLogViewStudent.center;

    
    
    
}
- (void)setColorArray:(NSArray *)colorArray{
    if (self.colorArray != colorArray) {
        _colorArray = colorArray;
    }
    //    NSString *teacherActivates = [NSString stringWithFormat: @"%ld",self.schoolPageInfoModel.teacherActivates];
    
    NSMutableAttributedString *mutableAttriteStuStr = [[NSMutableAttributedString alloc] init];
    NSAttributedString *attributeStuStr1 = [[NSAttributedString alloc] initWithString:[self.stringStudent substringWithRange:NSMakeRange(0,self.teacherActivates.length)] attributes:@{NSFontAttributeName :[UIFont fontWithName:@"Helvetica-Bold" size:((32 / 2) / kScreenHeight6) * kScreenHeight],NSForegroundColorAttributeName : colorArray[1],NSBackgroundColorAttributeName :WhiteColor}];
    NSAttributedString *attributeStuStr2 = [[NSAttributedString alloc] initWithString:[self.stringStudent substringWithRange:NSMakeRange(self.teacherActivates.length, self.stringStudent.length-self.teacherActivates.length)] attributes:@{NSFontAttributeName :font(20),NSForegroundColorAttributeName : colorArray[1],NSBackgroundColorAttributeName : WhiteColor}];
    [mutableAttriteStuStr appendAttributedString:attributeStuStr1];
    [mutableAttriteStuStr appendAttributedString:attributeStuStr2];
    
    self.lowMiddelStudentLable.attributedText = mutableAttriteStuStr;
    self.studentLable.textColor = colorArray[1];
    [self addSubview:self.lowMiddelStudentLable];
    
}
- (void)setCountArray:(NSArray *)countArray{
    if (self.countArray != countArray) {
        _countArray = countArray;
    }
    self.stringStudent = [NSString stringWithFormat: @"%@/%@", countArray[0],countArray[1]];
    self.teacherActivates = [NSString stringWithFormat: @"%@",countArray[0]];
    
}
@end
